package com.stox.core.util;

import java.util.ArrayList;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;

import com.stox.core.model.BarValueType;
import com.stox.core.model.IBar;

public class ListUtil {

	public static <T> void unique(List<T> list){
		Set<T> set = new LinkedHashSet<T>(list);
		list.clear();
		list.addAll(set);
	}
	
	public static List<Double> values(List<? extends IBar> bars, BarValueType barValueType){
		if(bars != null && barValueType != null){
			List<Double> values = new ArrayList<Double>(bars.size());
			for(IBar bar : bars){
				values.add(BarUtil.getValue(bar, barValueType));
			}
			return values;
		}
		return null;
	}
	
	
}
